package com.common.stdlib
{
	import com.common.stdlib.date.AfterDateHandler;
	import com.common.stdlib.date.AfterDateNoWeekend;
	import com.common.stdlib.date.AmountDay;
	import com.common.stdlib.date.BeforeDataHandler;
	import com.common.stdlib.date.DateAnimal;
	import com.common.stdlib.date.GreToLunarDate;
	import com.common.stdlib.date.MusicTimer;
	import com.common.stdlib.date.TianganDizhi;
	public class DateUtil
	{
		public static const DAY_WEEK 	:Array = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
		public static const MONTH_NUM 	:Array = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];
		public static const DATE_NUM	:Array = ["一","二","三","四","五","六","七","八","九","十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十","三十一"];
		public function DateUtil()
		{
		}
		/**
		 *转换时间格式 
		 * @param date
		 * @return 
		 * 
		 */		
		public static function formatDateString(date:Date):String
		{
			var y0:Number=date.fullYearUTC % 100;
			var y1:int=y0 / 10;
			var y2:int=y0 % 10;
			var year:String=y1.toString() + y2.toString();
			var text:String= /*year + "年" + */(date.month + 1) + "月" + date.date + "日" + (date.hours < 10 ? ("0" + date.hours) : date.hours) + "时"
			/*+ ":" +
			(date.minutes < 10?("0" + date.minutes):date.minutes) + ":" +
			(date.seconds < 10?("0" + date.seconds):date.seconds);*/
			return text;
		}
		/**
		 *返回月日字符串表示 
		 * @param date
		 * @return 
		 * 
		 */		
		public static function formatMonDayString(date:Date):String
		{
			var text:String = (date.month + 1) + "月" + date.date + "日";
			return text;
		}
		/**
		 *返回年月日字符串表示 
		 * @param date
		 * @return 
		 * 
		 */		
		public static function formatYearMonDayString(date:Date):String
		{
			var text:String = (date.fullYear) + "年" +  (date.month + 1) + "月" + date.date + "日";
			return text;
		}
		/**
		 *返回年月日时分秒字符串表示 
		 * @param date
		 * @return 
		 * 
		 */		
		public static function formatYearMonDayHSMString(date:Date):String
		{
			var text:String = (date.fullYear) + "年" +  (date.month + 1) + "月" + date.date + "日";
			text += " " + (date.hours < 10?"0" + date.hours:date.hours) + ":";
			text += (date.minutes < 10?"0" + date.minutes:date.minutes) + ":";
			text += (date.seconds < 10?"0" + date.seconds:date.seconds) + "";
			return text;
		}
		/**
		 *返回星期几格式
		 * @param date
		 * @return
		 */
		public static function getDayStr(date:Date):String
		{
			var day:int=date.day;
			return DAY_WEEK[day];
		}

		/**
		 *格式化時間，返回字符串
		 * @param date
		 * @param format
		 * @return
		 *
		 */
		public static function toDateCustomFormat(date:Date, format:String="YYYY-MM-DD JJ:NN:SS"):String
		{
			/*if(date==null)
			{
				return "date is null"
			}
			var dateFormat :DateFormatter = new DateFormatter();
			dateFormat.formatString = format;
			return dateFormat.format(date);*/
			return "";
		}

		/**
		 *比较两个日期的大小
		 * @param sourceDate
		 * @param distDate
		 * @return true(sourceDate >distDate)  false(sourceDate <= sourceDate)
		 *
		 */
		public static function compareTwoDate(sourceDate:Date, distDate:Date):Boolean
		{
			if (sourceDate == null || distDate == null)
			{
				throw new Error("Date is Null!");
			}
			var sourceDateTimes:Number=sourceDate.getTime();
			var distDateTimes:Number=distDate.getTime();
			if (sourceDateTimes > distDateTimes)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/**
		 *是否在两个日期之间 
		 * @return 
		 * 
		 */		
		public static function betweenTwoDate(soureDate :Date,
											  startDate:Date,
											  endDate:Date):Boolean
		{
			var sourceTimes		:Number = soureDate.getTime();
			var startTimes		:Number = startDate.getTime();
			var endTimes 		:Number = endDate.getTime();
			if(sourceTimes >= startTimes && sourceTimes <= endTimes)
			{
				return true;
			}
			return false;
		}
		/**
		 *
		 * @param startDate
		 * @param endDate
		 * @return
		 */
		public static function validateDates(startDate:Date, endDate:Date):Boolean
		{
			if (startDate == null && endDate == null)
			{
				return true;
			}
			if ((startDate != null && endDate == null) || (endDate != null && startDate == null))
			{
				//SamvoAlert.showText("Please select startDate or endDate!","Remind");
				return true;
			}

			if (compareTwoDate(startDate, endDate))
			{
				//SamvoAlert.showText("End date must greater than start date!","Error");
				return false;
			}

			return true;
		}

		/**
		 *
		 * @param str
		 * @return
		 *
		 */
		public static function parseDateString(str:String):Date
		{
			if (str == null)
			{
				return new Date();
			}

			//return DateFormatter.parseDateString(str);
			return new Date();
		}

		/**
		 *比较两个日期差 是否大于等于years
		 * @param birthday
		 * @param today
		 * @param years
		 * @return
		 *
		 */
		public static function validateTwoYear(birthday:Date, today:Date=null, years:int=18):Boolean
		{
			if (birthday == null)
			{
				return false;
			}

			if (today == null)
			{
				today=new Date();
			}

			var distYears:int=today.getFullYear() - birthday.getFullYear();

			if (distYears >= years)
			{
				return true;
			}

			return false;
		}

		/**
		 *格式化時間，返回当前日期的最大时间，比如2011-02-11 ，返回2011-02-11 23:59:59
		 * @param date
		 * @return
		 *
		 */
		public static function toDateMaxFormat(date:Date):Date
		{
			if (date == null)
			{
				return date;
			}
			var newDate:Date=new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
			return newDate;
		}

		/**
		 *格式化時間，返回当前日期的最小时间，比如2011-02-11 ，返回2011-02-11 00:00:00
		 * @param date
		 * @return
		 *
		 */
		public static function toDateMinFormat(date:Date):Date
		{
			if (date == null)
			{
				return date;
			}
			var newDate:Date=new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
			return newDate;
		}

		/**
		 *转换当前时间为GMT-4 Time Zone 时间
		 * @param data
		 * @return
		 *
		 */
		public static function transDateToGMTNegativeFour(date:Date):Date
		{
			if (date == null)
			{
				return null;
			}

			return new Date(date.setMilliseconds((date.getTimezoneOffset() - 240) * 60000));
		}

		/**
		 *
		 * @param date
		 * @return
		 *
		 */
		public static function transDateToNegativeFourHoursLater(date:Date):Date
		{
			if (date == null)
			{
				return null;
			}
			//trace("before");
			//trace(date.toLocaleString());
			var resDate:Date=new Date(date.setMilliseconds((240 - date.getTimezoneOffset()) * 60000));
			//trace("after");
			//trace(resDate.toLocaleString());
			return resDate;
		}
		/**
		 *转换字符串为时间 
		 * @param dateStr 2013-06-27 22:00:00
		 * @return 
		 */		
		public static function tranDateStrToDate(dateStr :String):Date
		{
			var date :Date;
			var myPattern:RegExp = /[-,:," "]/g;  
			dateStr = dateStr.replace(myPattern,"");
			var year 	:Number = Number(dateStr.substr(0,4));
			var month 	:Number = Number(dateStr.substr(4,2)) - 1;
			var day		:Number = Number(dateStr.substr(6,2));
			var hour	:Number = Number(dateStr.substr(8,2));
			var minute	:Number = Number(dateStr.substr(10,2));
			var second	:Number = Number(dateStr.substr(12,2));
			date = new Date(year,month,day,hour,minute,second);
			return date;
		}
		/**
		 * 比较两个时间
		 * @param fDate
		 * @param tDate
		 * @param seconds
		 * @return 如果fDate 大于等于 tDate + seconds 返回true，否则返回false.
		 */
		public static function validateBetweenTwoDate(fDate:Date, tDate:Date, seconds:int):Boolean
		{
			if (fDate == null || tDate == null)
			{
				return false;
			}
			var gap:Number=fDate.getTime() - tDate.getTime();
			if (gap >= (seconds * 1000))
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/**
		 * 格式 显示 时 分 秒 HH:MM:SS
		 * @param seconds
		 * @param isShowH 是否显示小时
		 * @return
		 *
		 */
		public static function formatShowHMS(seconds:int, isShowH:Boolean=false):String
		{
			var info:String="";
			var h:int;
			var m:int;
			var s:int;
			if (isShowH)
			{
				h=seconds / 3600;
				m=(seconds - h * 3600) / 60;
				s=seconds - (h * 3600 + m * 60);
				info=((h < 10) ? ("0" + h) : h) + ":" + ((m < 10) ? ("0" + m) : m) + ":" + ((s < 10) ? ("0" + s) : s);
			}
			else
			{
				m=seconds / 60;
				s=seconds - m * 60;
				info=((m < 10) ? ("0" + m) : m) + ":" + ((s < 10) ? ("0" + s) : s);
			}
			return info;
		}

		
		
		/**
		 *根据时间获取自然周 （时间范围星期一 --- 星期日）
		 * @param date
		 * 
		 */
		public static function getnatureWeek(date:Date):String
		{
			var cur:int = date.day ;
			if(cur <=0)cur = 7;
			var tempSecond:Number = date.getTime() - (cur - 1) * 24 * 3600 * 1000;
			var sunDate:Date = new Date(tempSecond);
			tempSecond = date.getTime() + (7 - cur)* 24 * 3600 * 1000;
			var monDate:Date = new Date(tempSecond);
			
			return sunDate.fullYear + "." + (sunDate.month+ 1) + "." + sunDate.date + "--——" +
				monDate.fullYear + "." + (monDate.month+ 1) + "." + monDate.date
		}
		
		
		
		//
		/**
		 * [开源项目]as3时间处理工具类
		 * 函数列表：
		 * <br/>
		 * dayNum                 得到指定的两个公历日期之间相差的天数  <br/>
		 * alreadyOverDay         指定的一年之内已经过了多少天了(算上当天)
		 * oneHour                一小时，即60分钟之内的秒数转化
		 * oneDay                 一天之内，即24小时之内的秒数转化
		 * anyMinutes             不限制在60分钟之内，只要是00:00格式的就行
		 * anyHours               不限制在24小时之内，只要是00:00:00格式的就行
		 * anyDays                所有时间的秒数转化
		 * isLeapYear             是否为闰年
		 * greMonthManyDays       指定公历年的某个月多少天
		 * manyWorkWeekDay        指定某公历年月内有几天工作日
		 * addDateNum             指定公历日期加上一定天数得到新日期
		 * delWeekendDaysAllNum   指定日期加上一定天数，返回加上后又减去周六日的总天数后的新日期
		 * minusDateNum           指定日期减去一定天数，返回减去后的新日期
		 * seqWeekOfMonth         指定公历日期所在周是当月的第几周
		 * seqWeekOfYear          指定公历日期所在周是当年的第几周
		 * objToTimeFormat        时间Date对象转化为标准时间格式YYYYMMDDHHMMSS
		 * yearAnimals            根据指定农历年份获得对应农历的生肖
		 * greToLunarArray        返回某公历年月日对应的农历年月日
		 * cyclical               获得指定农历年份的天干地支
		 * */
		//trace(dayNum("19881008", "20120315"));    //8559
		//trace(alreadyOverDay("20120315"));    //75,291

		//trace(oneHour(200));    //03:20
		//trace(oneDay(20000));    //05:33:20
		//trace(anyMinutes(1234567));    //20576:07
		//trace(anyHours(1234567));    //342:56:07
		//trace(anyDays(1234567));    //14-06:56:07

		//trace(isLeapYear(2012));    //true
		//trace(greMonthManyDays(2012, 2));    //29
		//trace(manyWorkWeekDay(2012, 3));    //22
		//trace(addDateNum(1988, 10, 8, 8560));    //2012/3/16
		//trace(delWeekendDaysAllNum(2012, 3, 20, 5));    //2012/3/27
		//trace(minusDateNum(2012, 3, 20, 8564));    //1988/10/8

		//trace(seqWeekOfMonth(2012, 3, 20));     //4
		//trace(seqWeekOfYear(2012, 3, 20));    //12

		//trace(objToTimeFormat(new Date()));    //20120320150356

		//trace(yearAnimals(1988));    //龙
		//trace(greToLunarArray(2012, 3, 20));    //2012,2,28,148,1359,40996,0
		//trace(cyclical(2012));    //壬辰
		/**
		 * 得到指定的两个公历日期之间相差的天数 <br/>
		 * 虽然名字为from和to， 两个参数所代表的开始和结束年份没有先后顺序
		 * @param $fromFormatDayStr 开始日期，格式如19881008
		 * @param $toFormatDayStr 结束日期，格式如20120315
		 * @return (int) 相差天数
		 * */
		public static function dayNum($fromFormatDayStr:String, $toFormatDayStr:String):int
		{
			return AmountDay.manyDayNum($fromFormatDayStr, $toFormatDayStr);
		}

		/**
		 * 指定的一年之内已经过了多少天了(算上当天) <br/>
		 * 要保证dayStr参数的格式和实际含义正确，如不能出现20100229
		 * @param $dayFormatStr 指定的日期，格式如20120315
		 * @return (Array) [0]表示已经过了多少天，[1]表示还剩下多少天
		 * */
		public static function alreadyOverDay($dayFormatStr:String):Array
		{
			return AmountDay.alreadyOverDay($dayFormatStr);
		}

		/**
		 * 一小时，即60分钟之内的秒数转化 <br/>
		 * 例如：oneHour(3599)     //59:59    //59分钟加59秒
		 * @param $second 描述，其范围是 0 <= $second < 3600
		 * @return (String) 标准指定的时间格式(1小时内)
		 * */
		public static function oneHour($second:int):String
		{
			return MusicTimer.oneHour($second);
		}

		/**
		 * 一天之内，即24小时之内的秒数转化 <br/>
		 * 如oneDay(86399) //23:59:59    //23小时加59分钟加59秒
		 * @param $second 其范围是 0 <= $second < 86400
		 * @return (String) 标准指定的时间格式(1天内)
		 * */
		public static function oneDay($second:int):String
		{
			return MusicTimer.oneDay($second);
		}

		/**
		 * 不限制在60分钟之内，只要是00:00格式的就行 <br/>
		 * 如anyMinutes(1234567)     //20576:07   //20576分钟加7秒
		 * @param $second 指定秒数
		 * @return (String) 标准指定的时间格式(XX:XX)
		 * */
		public static function anyMinutes($second:int):String
		{
			return MusicTimer.anyMinutes($second);
		}

		/**
		 * 不限制在24小时之内，只要是00:00:00格式的就行 <br/>
		 * 如anyHours(1234567)    //342:56:07    //342小时加56分钟加7秒
		 * @param $second 指定秒数
		 * @return (String) 标准指定的时间格式(XX:XX:XX)
		 * */
		public static function anyHours($second:int):String
		{
			return MusicTimer.anyHours($second);
		}

		/**
		 * 所有时间的秒数转化 <br/>
		 * 如anyDays(1234567)    //14-06:56:07    //14天加6小时加56分钟加7秒
		 * @param $second 其范围是 $second >= 0
		 * @return (String) 标准指定的时间格式(DD-DD:XX:XX)
		 * */
		public static function anyDays($second:int):String
		{
			return MusicTimer.anyDays($second);
		}

		/**
		 * 是否为闰年 <br/>
		 * @param $greYear dayStr标准格式为YYYY，如2010
		 * @return (Boolean) 是润年返回true，不是润年返回false
		 * */
		public static function isLeapYear($greYear:int):Boolean
		{
			if (($greYear % 4 == 0 && $greYear % 100 != 0) || $greYear % 400 == 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/**
		 * 指定公历年的某个月多少天
		 * @param $greYear 年份，如2012
		 * @param $greMonth 月份，如2
		 * @return (int) 指定公历年月的天数
		 * */
		public static function greMonthManyDays($greYear:int, $greMonth:int):int
		{
			const DAYS_IN_MONTH:Array=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
			var manyDayNum:int=DAYS_IN_MONTH[$greMonth - 1];
			if (isLeapYear2() && $greMonth == 2)
			{
				manyDayNum++;
			}
			function isLeapYear2():Boolean
			{
				if (($greYear % 4 == 0 && $greYear % 100 != 0) || $greYear % 400 == 0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			return manyDayNum;
		}

		/**
		 * 指定某公历年月内有几天工作日
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @reutrn (int) 返回指定月份工作日的天数
		 * */
		public static function manyWorkWeekDay($greYear:int, $greMonth:int):int
		{
			var restWeekNum:int=0;
			var date:Date=new Date($greYear, $greMonth - 1);
			var firstDayWeekNum:Number=date.getDay(); //每月的1号是星期几
			var manyDaysNum:int=greMonthManyDays($greYear, $greMonth);
			if (firstDayWeekNum >= 1 && firstDayWeekNum <= 5)
			{
				var numDateNum:int=27 - firstDayWeekNum;
				if (manyDaysNum == 31)
				{
					if (numDateNum == 22)
					{
						restWeekNum=10;
					}
					else if (numDateNum == 23)
					{
						restWeekNum=9;
					}
					else
					{
						restWeekNum=8;
					}
				}
				else if (manyDaysNum == 30)
				{
					if (numDateNum == 22)
					{ //这一号是星期五
						restWeekNum=9;
					}
					else
					{
						restWeekNum=8;
					}
				}
				else
				{ //每月有28天或29天
					restWeekNum=8;
				}
			}
			else if (firstDayWeekNum == 6)
			{ //周六
				restWeekNum=10;
				if (manyDaysNum == 28)
				{
					restWeekNum=8;
				}
				else if (manyDaysNum == 29)
				{
					restWeekNum=9;
				}
			}
			else if (firstDayWeekNum == 0)
			{ //周日
				if (manyDaysNum != 28)
				{
					restWeekNum=9;
				}
				else
				{
					restWeekNum=8;
				}
			}
			/*一个公历月有多少天*/
			function greMonthManyDays():Number
			{
				const DAYS_IN_MONTH:Array=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
				var manyDayNum:Number=DAYS_IN_MONTH[$greMonth - 1];
				if (isLeapYear3() && $greMonth == 2)
				{
					manyDayNum++;
				}
				return manyDayNum;
			}
			/*是否为闰年*/
			function isLeapYear3():Boolean
			{
				if (($greYear % 4 == 0 && $greYear % 100 != 0) || $greYear % 400 == 0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			return manyDaysNum - restWeekNum;
		}

		/**
		 * 指定公历日期加上一定天数得到新日期 <br/>
		 * 如addDateNum(1988, 10, 8, 7992));    //2010/8/26
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @param $manyDay 加的天数
		 * @return (String) 年/月/日
		 * */
		public static function addDateNum($greYear:Number, $greMonth:Number, $greDay:Number, $manyDay:Number):String
		{
			return AfterDateHandler.addDateNum($greYear, $greMonth, $greDay, $manyDay);
		}

		/**
		 * 指定日期加上一定天数，返回加上后又减去周六日的总天数后的新日期 <br/>
		 * 如delWeekendDaysAllNum(2012, 3, 20, 5);    //2012/3/27
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @param $manyDay 加的天数
		 * @return (String) 年/月/日
		 * */
		public static function delWeekendDaysAllNum($greYear:Number, $greMonth:Number, $greDay:Number, $addManyDaysNum:Number):String
		{
			return AfterDateNoWeekend.delWeekendDaysAllNum($greYear, $greMonth, $greDay, $addManyDaysNum);
		}

		/**
		 * 指定日期减去一定天数，返回减去后的新日期 <br/>
		 * 如minusDateNum(2012, 3, 20, 8564);    //
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @param $manyDay 减去的天数
		 * @return (String) 返回减后的日期:年/月/日
		 * */
		public static function minusDateNum($greYear:Number, $greMonth:Number, $greDay:Number, $manyDay:Number):String
		{
			return BeforeDataHandler.minusDateNum($greYear, $greMonth, $greDay, $manyDay);
		}

		/**
		 * 指定公历日期所在周是当月的第几周 <br/>
		 * 如seqWeekOfMonth(2012, 3, 20);     //4
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @return (Number) 返回当月内的周序列
		 * */
		public static function seqWeekOfMonth($greYear:Number, $greMonth:Number, $greDay:Number):Number
		{
			var date:Date=new Date($greYear, $greMonth - 1, $greDay);
			var diff:Number=date.getDate() - 1;
			date.setDate(1);
			var dateWeek:Number=7 - date.getDay();
			if (diff > dateWeek)
			{
				diff-=dateWeek;
				var dateMod:Number=diff % 7;
				if (dateMod > 0)
				{
					return (diff - dateMod) / 7 + 2;
				}
				else
				{
					return diff / 7 + 1;
				}
			}
			else
			{
				return 1;
			}
		}

		/**
		 * 指定公历日期所在周是当年的第几周 <br/>
		 * 如seqWeekOfYear(2012, 3, 20);    //12
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @return (Number) 返回当年内的周序列
		 * */
		public static function seqWeekOfYear($greYear:Number, $greMonth:Number, $greDay:Number):Number
		{
			var date:Date=new Date($greYear, $greMonth - 1, $greDay);
			var startDate:Date=new Date($greYear, 0, 1);
			var diff:Number=date.valueOf() - startDate.valueOf();
			var d:Number=Math.round(diff / 86400000);
			return Math.ceil((d + ((startDate.getDay() + 1) - 1)) / 7);
		}

		/**
		 * 时间Date对象转化为标准时间格式YYYYMMDDHHMMSS <br/>
		 * 如objToTimeFormat(new Date());    //20120320150356
		 * @param $date 指定的日期对象
		 * @return (String) 返回标准时间格式
		 * */
		public static function objToTimeFormat($date:Date):String
		{
			var yearStr:String=String($date.fullYear);
			var monthStr:String=String($date.month + 1);
			var dateStr:String=String($date.date);
			var hourStr:String=String($date.hours);
			var minutesStr:String=String($date.minutes);
			var secondStr:String=String($date.seconds);
			if ($date.month < 9)
			{
				monthStr="0" + monthStr;
			}
			if ($date.date < 10)
			{
				dateStr="0" + dateStr;
			}
			if ($date.hours < 10)
			{
				hourStr="0" + hourStr;
			}
			if ($date.minutes < 10)
			{
				minutesStr="0" + minutesStr;
			}
			if ($date.seconds < 10)
			{
				secondStr="0" + secondStr;
			}
			return yearStr + monthStr + dateStr + hourStr + minutesStr + secondStr;
		}
		
		/**
		 * 时间Date对象转化为显示时间格式YYYY-MM-DD HH:MM:SS <br/>
		 * 如objToTimeFormat(new Date());    //2012-03-20 15:03:56
		 * @param $date 指定的日期对象
		 * @return (String) 返回标准时间格式
		 * */
		public static function objToShowTimeFormat($date:Date):String
		{
			var yearStr:String=String($date.fullYear);
			var monthStr:String=String($date.month + 1);
			var dateStr:String=String($date.date);
			var hourStr:String=String($date.hours);
			var minutesStr:String=String($date.minutes);
			var secondStr:String=String($date.seconds);
			if ($date.month < 9)
			{
				monthStr="0" + monthStr;
			}
			if ($date.date < 10)
			{
				dateStr="0" + dateStr;
			}
			if ($date.hours < 10)
			{
				hourStr="0" + hourStr;
			}
			if ($date.minutes < 10)
			{
				minutesStr="0" + minutesStr;
			}
			if ($date.seconds < 10)
			{
				secondStr="0" + secondStr;
			}
			return yearStr + "-" + monthStr + "-" + dateStr + " " + hourStr + ":" + minutesStr + ":" + secondStr;
		}

		/**
		 * 根据指定农历年份获得对应农历的生肖 <br/>
		 * 如yearAnimals(1988);    //龙
		 * @param $greYear 指定农历年份
		 * @return (String) 生肖动物名称
		 * */
		public static function yearAnimals($lunarYear:int):String
		{
			return DateAnimal.yearAnimals($lunarYear);
		}

		/**
		 * 返回某公历年月日对应的农历年月日 <br/>
		 * 如greToLunarArray(2012, 3, 20);    //2012,2,28,148,1359,40996,0
		 * @param $greYear 公历年份
		 * @param $greMonth 公历月份
		 * @param $greDay 公历日期
		 * @return (Array) 返回指定公历年月日对应的农历年月日
		 * */
		public static function greToLunarArray($greYear:int, $greMonth:int, $greDay:int):Array
		{
			return GreToLunarDate.greToLunarArray($greYear, $greMonth, $greDay);
		}

		/**
		 * 获得指定农历年份的天干地支 <br/>
		 * 注:传入农历年份返回干支(此农历年份要大于等于1864) <br/>
		 * 如cyclical(2012);    //壬辰
		 * @param $lunarYear 指定的农历年份
		 * @return (String) 指定农历年份的天干地支
		 * */
		public static function cyclical($lunarYear:int):String
		{
			return TianganDizhi.cyclical($lunarYear);
		}
	}
}
